<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
namespace App\Admin\Controllers;

use App\Admin\Repositories\PointSetting;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;

class PointSettingController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new PointSetting(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('bonus_pool');
            $grid->column('entering_pool');
            $grid->column('release_daily');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
                $filter->between('created_at', '创建时间')->datetime();
                $filter->between('updated_at', '修改时间')->datetime();
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new PointSetting(), function (Show $show) {
            $show->field('id');
            $show->field('bonus_pool');
            $show->field('entering_pool');
            $show->field('release_daily');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new PointSetting(), function (Form $form) {
            $form->display('id');
            $form->text('secondary_dividend_points', '新零售倍率基数')->default(200);
            $form->text('base_number', '新零售直推基数')->default(230);
            $form->text('second_level_reward', '新零售直推奖励贡献值')->default(100);
//            $form->switch('on_bean', '开启通证分红')->default(0);
            $form->switch('on_point', '开启动态分红')->default(0);
            $form->switch('on_group', '开启静态分红')->default(0);
            $form->text('group_point_bonus_pool', '动态分红入池比例');
//            $form->text('group_bean_bonus_pool', '拼团通证池入池比例');
//            $form->text('product_point_bonus_pool', '新零售积分池入池比例');
//            $form->text('product_bean_bonus_pool', '新零售通证池入池比例');
//            $form->text('group_pool_price', '中单分红金');
            $form->list('group_pool_price_bonus', '静态分红发放区间');



            $form->text('reserve_pool', '储备池比例');


//            $form->text('group_reward_points', '拼团代金券奖励');
//            $form->text('combustion_integral', '拼团代金券手续费');

            $form->display('created_at');
            $form->display('updated_at');
            $form->saved(function (Form $form) {
                return $form->response()->success('操作成功')->redirect(request()->fullUrl() . '/edit');
            });
        });
    }
}
